<?php

namespace Trawind\Remotes\Repositories\User;

use Trawind\Remotes\BaseRepository;
use Trawind\Basics\Enums\ServiceDomain;
use Trawind\Remotes\Contracts\Repositories\User\UserRepository;

/**
 * Class UserRemoteEloquent.
 * @package namespace Trawind\Basics\Remotes\User;
 */
class UserRepositoryEloquent extends BaseRepository implements UserRepository
{

    public $baseRoute='/users';

    /**
     * UserRemoteEloquent constructor.
     */
    public function __construct()
    {
        $this->domain = ServiceDomain::USER_DOMAIN();
    }


    public function all($columns = ['*'])
    {
        return $this->setUrl($this->baseRoute)->result();
    }


    public function find($id, $columns = ['*'])
    {
        return $this->setUrl($this->baseRoute.'/'.$id)->result();
    }


    public function create(array $attributes)
    {
        return $this->setUrl($this->baseRoute)
            ->setClientOptions(['form_params' => $attributes])
            ->result('POST');
    }
    
    
    
    public function update(array $attributes, $id)
    {
        return $this->setUrl($this->baseRoute.'/'.$id)
            ->setClientOptions(['form_params' => $attributes])
            ->result('PUT');
    }
}
